<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box"></div>
    <div class="box"></div>
    <div id="box"></div>
    <script>
        //1.根据类名获得某些元素
        var a = document.getElementsByClassName('box');
        console.log(a);
        //2.返回指定选择器的第一个元素对象
        var firstBox = document.querySelector('.box');
        console.log(firstBox);
        var nav = document.querySelector('#box');
        console.log(nav);
        //3.根据指定返回器返回所有元素
        var box = document.querySelectorAll('.box');
        console.log(box);
    </script>
</body>

</html>